# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

# desc: password:
platform :ios do
  desc "Description of what the lane does"
  lane :Test_fastlane do |options|
    # cocoapods  # 执行 pod install

    gym(
      workspace: "JenkinsTest.xcworkspace",
      scheme: ENV['SCHEME_NAME'],
      # 打包前clean
      clean: true,
      # Release、Debug、自定义
      configuration: "Test_debug",
      # app-store, ad-hoc, package, enterprise, development
      export_method: "ad-hoc",
      # 文件输出路径
      output_directory: "/Users/junlianggan/Desktop/jenkins/JenkinsTest_fastlane/",
      # ipa名称
      output_name: ENV['API_NAME'],
      # 是否包含调试符号
      include_symbols: true,
      # 是否开启bitcode
      include_bitcode: false,
    )

    desc = options[:desc] 
    pgyer(
            # 蒲公英账号信息
            api_key: ENV['PGYER_API_KEY'], 
            user_key: ENV['PGYER_USER_KEY'], 
            # 设置下载密码
            password: "1234", 
            # 下载类型，1 - 公开安装，2 - 密码安装，3 - 邀请安装
            install_type: "2",
            # 设置更新描述
            update_description: "#{desc}"
        )

  end


#     lane :Test_uploadToAppStore do |options|
#     cocoapods  # 执行 pod install
#     gym(
#       workspace: "JenkinsTest.xcworkspace",
#       scheme: ENV('SCHEME_NAME'),
#       # 打包前clean
#       clean: true,
#       # Release、Debug、自定义
#       configuration: "Test_debug",
#       # app-store, ad-hoc, package, enterprise, development
#       export_method: "ad-hoc",
#       # 文件输出路径
#       output_directory: "/Users/junlianggan/Desktop/JenkinsTest_fastlane/",
#       # ipa名称
#       output_name: ENV('API_NAME'),
#       # 是否包含调试符号
#       include_symbols: true,
#       # 是否开启bitcode
#       include_bitcode: false,
#     )

#     #上传到appStore
#     deliver(
#         submit_for_review: false,   #上传后自动提交审核
#         automatic_release: false,   #过审后自动发布
#         skip_binary_upload: false,  #跳过上传二进制文件
#         skip_screenshots: false,    #跳过上传截图
#         skip_metadata: false,       #跳过元数据
#         force: false,         #上传之前不生成html报告
#         price_tier: 0,        #应用价格等级
#         overwrite_screenshots: true,  #是否覆盖ITC上已有的截图
#         app_icon: "./fastlane/1024.png",     #icon, 必须为1024*1024
#         screenshots_path: "./fastlane/screenshots"      #截图路径
#     )

#   end

end
